package com.muqi.app.user.widget;

import org.jivesoftware.smack.util.dns.SRVRecord;

import com.muqi.app.project.utils.ScreenUtils;
import com.muqi.app.qlearn.student.R;

import android.R.layout;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;

import android.view.LayoutInflater;
import android.view.View;

import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;

import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.PopupWindow.OnDismissListener;

public class VipWindow implements OnDismissListener, OnClickListener {
	private Activity mActivity;

	private PopupWindow window;
	
	private TextView tv_time;
	
	
	@SuppressLint("InflateParams") 
	public VipWindow(Activity mActivity){
		this.mActivity = mActivity;
		
		window = new PopupWindow(mActivity);
		window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
		
		View contentView = LayoutInflater.from(mActivity).inflate(R.layout.popup_vip, null);
		tv_time= (TextView)contentView.findViewById(R.id.item_vip_time);
	
		window.setContentView(contentView);
		window.setWidth(LayoutParams.MATCH_PARENT);
		window.setHeight(LayoutParams.WRAP_CONTENT);
		window.setFocusable(true); //默认为false,如果不设置为true，PopupWindow里面是获取不到焦点的，那么如果PopupWindow里面有输入框等的话就无法输入。
		window.setTouchable(true); // 设置PopupWindow可触摸
		window.setOutsideTouchable(true);
		window.setOnDismissListener(this);
		ColorDrawable dw = new ColorDrawable(0000000000);
		window.setBackgroundDrawable(dw);
	}

	@Override
	public void onDismiss() {
		
	}
	
	/**弹窗显示的位置*/  
	public void showAsDropDown(View parent){
		if(window.isShowing()){
			return;
		}
		window.showAsDropDown(parent, 0, 0);

	}
	
	/**消除弹窗*/
	public void dissmiss(){
		window.dismiss();
	}
	
	
	@Override
	public void onClick(View v) {
		
	}
	public void setTime(String time){
		tv_time.setText(time);
	}
	
	
}
